<script type="text/javascript" src="../scripts/date.js"></script>
<script type="text/javascript">
	cotCanHien[0] = 2;
	function guiform() 
	{  
		 document.formgui.submit(); 
	}
	function tatToan() {
		if(confirm('Bạn có muốn tất toán không (sẽ không tất toán được nữa?)'))
			return true;
		else 
			return false;
	}
	function jsmaphongban(){   
		MaPB = $("#MaPB").val();
		$.post( 
				 "../adm/nhanvien/getmanguoidung.php",
				 { MaPB:  MaPB },
				 function(data) {
					$('#showmanguoidung').html(data);
					
				 }
		  
		);
	}

	function ChuyenMaKhachHang(MaKH){
		document.getElementById('MaKH').value = MaKH;
	}

	function GetThongTinKhachHang(MaKH){
		var xmlHttp;
	    if(window.XMLHttpRequest){
	        xmlHttp = new XMLHttpRequest;
	    }
	    else if(window.ActiveXObject){
	        xmlHttp = new ActiveXObject('Microsoft.XMLHTTP');
	    }
	    
	    xmlHttp.onreadystatechange = function(){
	        if(xmlHttp.readyState == 4){
	            var thongTin = xmlHttp.responseText;
	            var mangThongTin = thongTin.split("|");
	            document.getElementById('DiaChi').value = mangThongTin[0];
	            document.getElementById('SoCMND').value = mangThongTin[1];
	            document.getElementById('NgayCap').value = mangThongTin[2];
	            document.getElementById('NoiCap').value = mangThongTin[3];
	        }
	    }
	    xmlHttp.open('GET', '../adm/nhanvien/sotietkiem/getthongtinkhachhang.php?makh='+MaKH, true);
	    xmlHttp.send(null);
	}
	
	function getKyHan(MaKyHan){
	 	var xmlHttp;
	    if(window.XMLHttpRequest){
	        xmlHttp = new XMLHttpRequest;
	    }
	    else if(window.ActiveXObject){
	        xmlHttp = new ActiveXObject('Microsoft.XMLHTTP');
	    }
	    
	    xmlHttp.onreadystatechange = function(){
	        if(xmlHttp.readyState == 4){
	            document.getElementById('KyHan').value = xmlHttp.responseText;
	        }
	    }
	    xmlHttp.open('GET', '../adm/nhanvien/sotietkiem/getkyhan.php?makyhan='+MaKyHan, true);
	    xmlHttp.send(null);
	}

	function ganNgayHieuLuc(MaKyHan){
		var xmlHttp;
	    if(window.XMLHttpRequest){
	        xmlHttp = new XMLHttpRequest;
	    }
	    else if(window.ActiveXObject){
	        xmlHttp = new ActiveXObject('Microsoft.XMLHTTP');
	    }
	    
	    xmlHttp.onreadystatechange = function(){
	        if(xmlHttp.readyState == 4){
	            var KyHan = xmlHttp.responseText;
	    		var currentDate = document.getElementById('NgayMoSo').value;
	    		var mangNgay = currentDate.split("-");
	    		var d = new Date(mangNgay[0],mangNgay[1],mangNgay[2]);
	    		var ngayToiHan = d.addMonths(Number(KyHan)); 
	    		document.getElementById('NgayDenHan').value = ngayToiHan.getFullYear()+"-"+(ngayToiHan.getMonth())+"-"+ngayToiHan.getDate();
	        }
	    }
	    xmlHttp.open('GET', '../adm/nhanvien/sotietkiem/getkyhan.php?makyhan='+MaKyHan, true);
	    xmlHttp.send(null);
	}
	function ajaxFunction(){
	    var xmlHttp;
	    var MaKyHan = document.getElementById('MaKyHan').value;
	    var HinhThucThangNam = document.getElementById('HinhThucThangNam').value;
	    if(window.XMLHttpRequest){
	        xmlHttp = new XMLHttpRequest;
	    }
	    else if(window.ActiveXObject){
	        xmlHttp = new ActiveXObject('Microsoft.XMLHTTP');
	    }
	    
	    xmlHttp.onreadystatechange = function(){
	        if(xmlHttp.readyState == 4){
	            document.getElementById('LaiSuat').value = xmlHttp.responseText;
	        }
	    }
	    xmlHttp.open('GET', '../adm/nhanvien/sotietkiem/getlaisuat.php?makyhan='+MaKyHan+'&hinhthuc='+HinhThucThangNam, true);
	    xmlHttp.send(null);
	}
	function checkHTLanhLai() {
		 var xmlHttp;
	    var MaKyHan = document.getElementById('MaKyHan').value;
	    var MaHTLanhLai = document.getElementById('MaHTLanhLai').value;
	    if(window.XMLHttpRequest){
	        xmlHttp = new XMLHttpRequest;
	    }
	    else if(window.ActiveXObject){
	        xmlHttp = new ActiveXObject('Microsoft.XMLHTTP');
	    }
	    
	    xmlHttp.onreadystatechange = function(){
	        if(xmlHttp.readyState == 4){
	            var ketQuaCheck = xmlHttp.responseText;
	     			if(ketQuaCheck=="false")
	     			{
		            	alert('Hình thức lãnh lãi không được lớn hơn kỳ hạn');
		            	document.getElementById('MaHTLanhLai').value = 0;
		            	document.getElementById('NgayLanhLai').value = "";
	     			}
	        }
	    }
	    xmlHttp.open('GET', '../adm/nhanvien/sotietkiem/checkhinhthuclanhlai.php?makyhan='+MaKyHan+'&htlanhlai='+MaHTLanhLai, true);
	    xmlHttp.send(null);
	}
	function ganNgayLanhLai(){
		 var MaHTLanhLai = document.getElementById('MaHTLanhLai').value;
		var xmlHttp;
	    if(window.XMLHttpRequest){
	        xmlHttp = new XMLHttpRequest;
	    }
	    else if(window.ActiveXObject){
	        xmlHttp = new ActiveXObject('Microsoft.XMLHTTP');
	    }
	    
	    xmlHttp.onreadystatechange = function(){
	        if(xmlHttp.readyState == 4){
	            var HTLanhLai = xmlHttp.responseText;
	            var currentDate = document.getElementById('NgayMoSo').value;
	    		var mangNgay = currentDate.split("-");
	    		var d = new Date(mangNgay[0],mangNgay[1],mangNgay[2]);
	    		var ngayToiHan = d.addMonths(Number(HTLanhLai)); 
	    		document.getElementById('NgayLanhLai').value = ngayToiHan.getFullYear()+"-"+(ngayToiHan.getMonth())+"-"+ngayToiHan.getDate();
	        }
	    }
	    xmlHttp.open('GET', '../adm/nhanvien/sotietkiem/gethtlanhlai.php?mahtlanhlai='+MaHTLanhLai, true);
	    xmlHttp.send(null);
	}
</script>
<?php
	$sotietkiem = new sotietkiembs();
	$danhsach = $sotietkiem->LayDanhSachCoKyHan();
	session_start();
	$nhatky = new nhatkybs();
	$nhatky->TenSuKien = "Xem danh sách sổ tiết kiệm có kỳ hạn";
	$nhatky->MaNguoiDung = $_SESSION["MaND"];
	date_default_timezone_set('Asia/Ho_Chi_Minh');
	$nhatky->ThoiGian = date("Y-m-d H:m:s", time());
	$nhatky->Them();
?>
<form name="formgui"  method="POST" action="">
<table id="rounded-corner" class="display" summary="Danh sách sổ tiết kiệm" border="1">
	<thead>
		<tr>
			<th align="center" colspan="13">
	               	<h2><strong>DANH SÁCH SỔ TIẾT KIỆM</strong></h2>
			</th>
		</tr>
		<tr>					
			<th scope="col" class="rounded">STT</th>
			<th scope="col" class="rounded">Số sổ</th>
			<th scope="col" class="rounded">Tài khoản</th>
			<th scope="col" class="rounded">Ngày mở sổ</th>
			<th scope="col" class="rounded">Ngày đến hạn</th>
			<th scope="col" class="rounded">Ngày lãnh lãi</th>		
			<th scope="col" class="rounded">Số tiền gửi</th>
			<th scope="col" class="rounded">Tiền lãi</th>			
			<th scope="col" class="rounded">Số dư kỳ TT</th>
			<th scope="col" class="rounded">Số tiền nhận</th>
			<th scope="col" class="rounded">Tất toán</th>
			<th scope="col" class="rounded">Sao kê</th>
			<th scope="col" class="rounded">Rút tiền</th>
		</tr>
	</thead>
	<tfoot>
            <tr>
            	<th>STT</th>
            	<th>Số sổ</th>
                <th>Tài khoản</th>
                <th>Ngày mở sổ</th>
                <th>Ngày đến hạn</th> 
                <th>Ngày lãnh lãi</th>          
                <th>Số tiền gửi</th>
                <th>Tiền lãi</th>                            
                <th>Số dư kỳ TT</th>
                <th>Số tiền nhận</th>          
                <th>Tất toán</th>
                <th>Sao kê</th> 
                <th>Rút tiền</th>         
            </tr>
    </tfoot>
	<tbody>
		<?php
		$stt = 1;
		for($i = 0; $i < ($danhsach == false ? 0 : count($danhsach)); $i++)
		{
				$Khoa = $danhsach[$i]["Khoa"];
				$Active = "<img src='images/active.png' alt='Khóa sổ' title='' border='0' />";
				$Disable = "<img src='images/khoa.png' alt='Khóa sổ' title='' border='0' />";
				echo "<tr>";
					echo "<td>" . ($i + 1) . "</td>";
					echo "<td><a onclick='toggleSua();' href='index.php?do=sotietkiemcokyhan&id={$danhsach[$i]["MaSoTietKiem"]}'>{$danhsach[$i]['MaSoTietKiem']}</a></td>";
					echo "<td>{$danhsach[$i]['MaKH']}</td>";
					echo "<td>{$danhsach[$i]['NgayMoSo']}</td>";
					echo "<td>{$danhsach[$i]['NgayDenHan']}</td>";
					echo "<td>{$danhsach[$i]['NgayLanhLai']}</td>";
					echo "<td>{$danhsach[$i]['SoTienGui']}</td>";
					echo "<td>{$danhsach[$i]['LaiDaTra']}</td>";									
					echo "<td>{$danhsach[$i]['SoDuKyHanTT']}</td>";
					echo "<td>{$danhsach[$i]['SoTienNhan']}</td>";
					echo "<td>";
					if ($Khoa == 0)
						echo $Active;
					else
						echo $Disable;				
					echo "</td>";										
						echo "<td><a href='index.php?do=saokesotietkiemcokyhan&id={$danhsach[$i]["MaSoTietKiem"]}' ><img src='images/printer.png' alt='Sao kê' title='' border='0' /></a></td>";
					if($Khoa==0)
					{
						if($danhsach[$i]['SoDuKyHanTT'] !=0)
							echo "<td><a href='index.php?do=rutsotietkiem&id={$danhsach[$i]["MaSoTietKiem"]}' ><img src='images/coins.png' alt='Rút tiền' title='' border='0' /></a></td>";
						else 
							echo "<td><img src='images/khoa.png'></td>";
					}
					else 
					{
						echo "<td><img src='images/khoa.png'></td>";
					}
				echo "</tr>";
					$stt++;
					}
			?>
	</tbody>
</table>
</form>
<br/>
<br/>
<?php
	$sotietkiem = new sotietkiembs();
	$sotietkiem->MaSoTietKiem = $_GET["id"];
	$danhsach = $sotietkiem->LayDanhSach();
?>

<br/>
 <div class="form" id="tdSua" style="<?php if($_GET['id']!="") echo "display:block"; else echo "display:none"; ?>">
<form enctype="multipart/form-data" name="formgui"  method="post" action="index.php?do=suasotietkiemcokyhan_xuly" onsubmit="return checkPostArtForm(this);">
<h2>
	<strong>Thông tin sổ tiết kiệm</strong>
</h2>
<table style="width:950px; margin-left: 10px; table-layout: fixed;">
		<tr>
			<td style="width:20px;padding-top:10px;">
	        	<label for="masotietkiem">Số sổ:</label>
	        </td>
	        <td style="width:60px;padding-top:10px;">
	            <input readonly="readonly" tabindex="1" type="text" name="MaSoTietKiem" class="txt" size="54" value="<?php echo $danhsach[0]["MaSoTietKiem"];?>"/>   
	        </td>
	        <td style="width:20px;padding-top:10px;">

	        </td>
	        <td style="width:60px;padding-top:10px;">

	        </td>
		</tr>
		<tr>
			<td style="padding-top:10px;">
	        	<label for="tenkhachhang">Khách hàng:</label>        	
	        </td>	       
			<td style="padding-top:10px;">
				<select disabled="disabled" name="TenKhachHang" onchange="ChuyenMaKhachHang(this.value);GetThongTinKhachHang(this.value);">	
            		<option value="0">-- Chọn khách hàng --</option>	                      	
					<?php
						$khachhang = new khachhangbs();
						$danhsachkhachhang = $khachhang->LayDanhSach();
						for($j = 0; $j < ($danhsachkhachhang != false ? count($danhsachkhachhang) : 0); $j++)
						{	
							$HoTen = $danhsachkhachhang[$j]['Ho'] . " "	. $danhsachkhachhang[$j]['Ten'];
							if($danhsachkhachhang[$j]["MaKH"]==$danhsach[0]["MaKH"])	
								echo "<option selected value='{$danhsachkhachhang[$j]["MaKH"]}'>{$HoTen}</option>";
							else 
								echo "<option value='{$danhsachkhachhang[$j]["MaKH"]}'>{$HoTen}</option>";
						}
					?>
				</select>
			</td>
			<td style="padding-top:10px;">
	        	<label for="makhachhang">Tài khoản:</label>      	
	        </td>
			 <td style="padding-top:10px;">
	        	<input readonly="readonly" tabindex="1" type="text" id="MaKH" name="MaKH" class="txt" size="12" value="<?php echo $danhsach[0]["MaKH"];?>" /> 
	        </td>
		</tr>
		<?php 
			$kh = new khachhangbs();
			$kh->MaKH = $danhsach[0]["MaKH"];
			$dskhachhang = $kh->LayDanhSach();
		?>
		<tr>
			<td style="padding-top:10px;">
	        	<label for="diachi">Địa chỉ:</label>         	
	        </td>	       
			<td style="padding-top:10px;">
	        	<input readonly="readonly" tabindex="1" type="text" id="DiaChi" name="DiaChi" class="txt" size="12" value="<?php echo $dskhachhang[0]["DiaChi"];?>" /> 
	        </td>
			<td style="padding-top:10px;">
	        	<label for="socmnd">Số CMND:</label>        	
	        </td>
			 <td style="padding-top:10px;">
	        	<input readonly="readonly" tabindex="1" type="text" id="SoCMND" name="SoCMND" class="txt" size="12" value="<?php echo $dskhachhang[0]["SoCMND"];?>" /> 
	        </td>
		</tr>
		<tr>
			<td style="padding-top:10px;">
	        	<label for="ngaycap">Ngày cấp:</label>          	
	        </td>	       
			<td style="padding-top:10px;">
	        	<input readonly="readonly" tabindex="1" type="text" id="NgayCap" name="NgayCap" class="txt" size="12" value="<?php echo $dskhachhang[0]["NgayCap"];?>" /> 
	        </td>
			<td style="padding-top:10px;">
	        	<label for="noicap">Nơi cấp:</label>        	
	        </td>
			 <td style="padding-top:10px;">
	        	<input readonly="readonly" tabindex="1" type="text" id="NoiCap" name="NoiCap" class="txt" size="12" value="<?php echo $dskhachhang[0]["NoiCap"];?>" /> 
	        </td>
		</tr>		
		<tr>
			<td style="padding-top:10px;">
	        	<label for="loaitietkiem">Loại kỳ hạn:</label>&nbsp<span class="requirefield">*</span>
	        </td>
			<td style="padding-top:10px;">
				<select name="MaKyHan" onchange="ajaxFunction();getKyHan(this.value);ganNgayHieuLuc(this.value);checkHTLanhLai(this.value);" id ="MaKyHan">	
            		<option value="0">-- Chọn kỳ hạn --</option>	                      	
					<?php
						$kyhan = new loaikyhanbs();
						$danhsachkyhan = $kyhan->LayDanhSach();
						for($j = 1; $j < ($danhsachkyhan != false ? count($danhsachkyhan) : 1); $j++)
						{
							if($danhsachkyhan[$j]["MaLoaiKyHan"]==$danhsach[0]["MaLoaiKyHan"])		
								echo "<option selected value='{$danhsachkyhan[$j]["MaLoaiKyHan"]}'>{$danhsachkyhan[$j]["TenLoaiKyHan"]}</option>";
							else 
								echo "<option value='{$danhsachkyhan[$j]["MaLoaiKyHan"]}'>{$danhsachkyhan[$j]["TenLoaiKyHan"]}</option>";
						}
					?>
				</select>			
			</td>
			<td style="padding-top:10px;">
				<label for="laisuat">Lãi suất:</label>
	        </td>
			<td style="padding-top:10px;">
				<?php
					$laisuatgui = new laisuatguibs();
					$laisuatgui->MaLaiSuatGui = $danhsach[0]["MaLaiSuatGui"];
					$dslaisuatgui = $laisuatgui->LayDanhSach();
				?>
				<input readonly="readonly" tabindex="1" type="text" id="LaiSuat" name="LaiSuat" class="input" size="12" value="<?php echo $dslaisuatgui[0]["PhanTramLaiSuatGui"];?>" />%	       
		        &nbsp
		        <select id ="HinhThucThangNam" name="HinhThucThangNam" onchange="ajaxFunction();">	                      	
						<option <?php if($dslaisuatgui[0]["HangThang"]==1) echo "selected";?> value="Thang">Tháng</option>
						<option <?php if($dslaisuatgui[0]["HangNam"]==1) echo "selected";?> value="Nam">Năm</option>
				</select>
			 </td>
		</tr>
		<tr>
			<td style="width:15px;padding-top:10px;">
	        	<label for="kyhan">Kỳ hạn:</label>
	        </td>
	        <td style="width:60px;padding-top:10px;">
	        	<?php 
	        		$kyhan_2 = new loaikyhanbs();
	        		$kyhan_2->MaLoaiKyHan = $danhsach[0]["MaLoaiKyHan"];
	        		$danhsachkyhan_2 = $kyhan_2->LayDanhSach();
	        	?>
	            <input readonly="readonly" tabindex="1" type="text" id="KyHan" name="KyHan" class="txt" size="12" value="<?php echo $danhsachkyhan_2[0]["KyHan"];?>" />
	        </td>
		</tr>
		<tr>
			<td style="width:15px;padding-top:10px;">
	        	<label for="hinhthuclanhlai">Hình thức lãnh lãi:</label>&nbsp<span class="requirefield">*</span>
	        </td>
	        <td style="width:60px;padding-top:10px;">
	        	<select name="MaHTLanhLai" id="MaHTLanhLai" onchange="checkHTLanhLai(this.value);ganNgayLanhLai(this.value);">	
            		<option value="0">-- Chọn hình thức lãnh lãi --</option>	                      	
					<?php
						$hinhthuclanhlai = new hinhthuclanhlaibs();
						$danhsachhinhthuclanhlai = $hinhthuclanhlai->LayDanhSach();
						for($j = 0; $j < ($danhsachhinhthuclanhlai != false ? count($danhsachhinhthuclanhlai) : 0); $j++)
						{
							if($danhsachhinhthuclanhlai[$j]["MaHTLanhLai"] == $danhsach[0]["MaHTLanhLai"])		
								echo "<option selected value='{$danhsachhinhthuclanhlai[$j]["MaHTLanhLai"]}'>{$danhsachhinhthuclanhlai[$j]["TenHTLanhLai"]}</option>";
							else 
								echo "<option value='{$danhsachhinhthuclanhlai[$j]["MaHTLanhLai"]}'>{$danhsachhinhthuclanhlai[$j]["TenHTLanhLai"]}</option>";
						}
					?>
				</select>
	        </td>
	        <td style="padding-top:10px;">
	        	<label for="ngaymoso">Ngày lãnh lãi:</label>
	        </td>
			<td style="padding-top:10px;">
				<input readonly="readonly" tabindex="1" type="text" id="NgayLanhLai" name="NgayLanhLai" class="txt" size="12" value="<?php echo $danhsach[0]["NgayLanhLai"];?>" />
			</td>
		</tr>
		<tr>
			<td style="padding-top:10px;">
	        	<label for="ngaymoso">Ngày mở sổ:</label>
	        </td>
			<td style="padding-top:10px;">
				<input readonly="readonly" tabindex="1" type="text" id="NgayMoSo" name="NgayMoSo" class="txt" size="12" value="<?php echo $danhsach[0]["NgayMoSo"];?>" />
			</td>
			<td style="padding-top:10px;">
				<label for="ngaydenhan">Ngày đến hạn:</label>
	        </td>
			<td style="padding-top:10px;">
				<input readonly="readonly" tabindex="1" type="text" id="NgayDenHan" name="NgayDenHan" class="txt" size="12" value="<?php echo $danhsach[0]["NgayDenHan"];?>" />
	        </td>
		</tr>
		<tr>
			<td style="width:15px;padding-top:10px;">
	        	<label for="sotiengui">Số tiền gửi:</label>&nbsp<span class="requirefield">*</span>    
	        </td>
	        <td style="width:60px;padding-top:10px;">
	            <input tabindex="1" type="text" name="SoTienGui" class="txt" value="<?php echo $danhsach[0]["SoTienGui"];?>" />   
	        </td>
	        <td style="width:15px;padding-top:10px;">
				<label for="loaitiengui">Loại tiền gửi:</label>
	        </td>
	        <td style="width:60px;padding-top:10px;">
				<input readonly="readonly" tabindex="1" type="text" id="LoaiTienGui" name="LoaiTienGui" class="txt" size="12" value="VND" />
	        </td>       
		</tr>
		<tr>
			<td colspan="0">
			<hr>
			</td>
		</tr>
		<tr>
			<td style="width:15px;padding-top:10px;">
	        	<label for="sobuttoan">Số bút toán:</label>
	        </td>
	        <?php 
	        	$kekhaigiaodich = new kekhaigiaodichbs();
	        	$kekhaigiaodich->MaSoTietKiem = $danhsach[0]["MaSoTietKiem"];
	        	$dskekhaigiaodich = $kekhaigiaodich->LayDanhSach();
	        ?>
	        <td style="width:60px;padding-top:10px;">
	            <input readonly="readonly" tabindex="1" type="text" name="SoButToan" class="txt" size="54" value="<?php echo $dskekhaigiaodich[0]["SoButToan"];?>"/>   
	        </td>
	        <td style="width:20px;padding-top:10px;">

	        </td>
	        <td style="width:60px;padding-top:10px;">

	        </td>
		</tr>
		<tr>
			<td style="width:15px;padding-top:10px;">
	        	<label for="nhanvienlapso">Nhân viên lập sổ:</label>
	        </td>
	        <td style="width:60px;padding-top:10px;">
	        	<?php 
	        		$nguoidung = new nguoidungbs();
	        		$nguoidung->MaNguoiDung = $_SESSION["MaND"];
	        		$danhsach = $nguoidung->LayDanhSach();
	        		$HoTen = $danhsach[0]["Ho"]." ".$danhsach[0]["Ten"];
	        	?>
	        	<input type="hidden" name="MaNhanVien" value="<?php echo $danhsach[0]['MaNguoiDung'] ?>"/>
	            <input readonly="readonly" tabindex="1" type="text" name="TenNhanVien" class="txt" size="54" value="<?php echo $HoTen; ?>"/>   
	        </td>
	        <td style="width:15px;padding-top:10px;">
	        	<label for="loaigiaodich">Loại giao dịch:</label> 
	        </td>
	        <td style="width:60px;padding-top:10px;">
	        	<select name="MaLoaiGiaoDich">	
            		<option value="0">-- Chọn loại giao dịch --</option>                      	
					<?php
						$kekhaigiaodich = new kekhaigiaodichbs();
						$kekhaigiaodich->SoButToan = $danhsach[0]["SoButToan"];
						$dskekhaigiaodich = $kekhaigiaodich->LayDanhSach();
						$loaigiaodich = new loaigiaodichbs();
						$dsloaigiaodich = $loaigiaodich->LayDanhSach();
						for($j = 0; $j < ($dsloaigiaodich != false ? count($dsloaigiaodich) : 0); $j++)
						{	
							if($dsloaigiaodich[$j]["MaLoaiGiaoDich"] == $dskekhaigiaodich[0]["MaLoaiGiaoDich"])
								echo "<option selected value='{$dsloaigiaodich[$j]["MaLoaiGiaoDich"]}'>{$dsloaigiaodich[$j]["TenLoaiGiaoDich"]}</option>";
							else 
								echo "<option value='{$dsloaigiaodich[$j]["MaLoaiGiaoDich"]}'>{$dsloaigiaodich[$j]["TenLoaiGiaoDich"]}</option>";
						}
					?>
				</select>		
	        </td>	
	      </tr>
		<p class="requirefields">(*): Các trường bắt buộc phải có.</p>
</table>
<br/>
<br/>
<p align="center">
	<input type="submit" class="button small blue" value="Cập nhật"/>
	&nbsp &nbsp
	<a href="index.php?do=inphieuthu&id=<?php echo $_GET["id"];?>" class="button small blue">In phiếu gửi tiền</a>	
</p>
</form>
</div>
<?php
	if(isset($_SESSION["LoiSuaTietKiemCo"]))
	{
		echo $_SESSION["LoiSuaTietKiemCo"];
		unset($_SESSION["LoiSuaTietKiemCo"]);
	}
?>

<script type="text/javascript">
 
function checkPostArtForm(frm)
{
	if(frm.MaKyHan.value==0)
	{
		alert('Bạn chưa chọn kỳ hạn!');
		frm.MaKyHan.focus();
		return false;
	}
	if(frm.MaHTLanhLai.value==0 && frm.MaHTLanhLai.disabled ==false)
	{
		alert('Bạn chưa chọn hình thức lãnh lãi!');
		frm.MaHTLanhLai.focus();
		return false;
	}
	if(frm.SoTienGui.value=="")
	{
		alert('Bạn chưa nhập số tiền gửi!');
		frm.SoTienGui.focus();
		return false;
	}
	var numberRe = /^[0-9]+$/;
	if(!frm.SoTienGui.value.match(numberRe))
	{	
		alert('Số tiền gửi không hợp lệ.');
		frm.SoTienGui.focus();
		return false;
	}

	if(frm.SoTienGui.value < 500000|| frm.SoTienGui.value > 1000000000)
	{
		alert('Số tiền gửi phải >= 500 ngàn và <= 1 tỷ đồng!');
		frm.SoTienGui.focus();
		return false;
	}
	
    return true;
}
</script>